package com.lzw.breezeNovel.webApp.controller.Ai;


import com.lzw.breezeNovel.common.result.Result;
import com.lzw.breezeNovel.model.entity.pojo.Ai.AiVideo;
import com.lzw.breezeNovel.model.entity.query.Ai.ImageQuery;
import com.lzw.breezeNovel.model.entity.query.Ai.VideoQuery;
import com.lzw.breezeNovel.webApp.service.Ai.AiSercive;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author 清风明月
 * @Package com.lzw.breezeNovel.webApp.controller.Ai
 * @date 2025/3/19
 * @description 人工智能
 */
@RestController
@RequestMapping("/app/ai")
@SuppressWarnings("all")
public class AiController {
    /**
     * 注入service
     */
    @Autowired
    private  AiSercive aiSercive;

    /**
     * 多轮对话流式输出接口
     *
     * @param conversationId 对话会话ID
     * @param userContent    用户输入内容
     * @return 流式输出的AI回复
     */
    @GetMapping("/chat")
    public Result<String> chat(@RequestParam String userContent) {
        String content = aiSercive.chat(userContent);
        return Result.ok(content);
    }

    /**
     * 图片生成
     */
    @PostMapping("/img")
    public Result<List<String>> img(@RequestBody ImageQuery imageQuery) {
        List<String> images = aiSercive.img(imageQuery);
        return Result.ok(images);
    }

    /**
     * 文字生成视频
     */
    @PostMapping("/textVideo")
    public Result<String> video(@RequestBody VideoQuery videoQuery) {
        String videoUrl = aiSercive.video(videoQuery);
        return Result.ok(videoUrl);
    }

    /**
     * 图片生成视频
     */
    @PostMapping("/imgVideo")
    public Result<String> imgVideo(@RequestBody VideoQuery videoQuery) {
        String videoUrl = aiSercive.imgVideo(videoQuery);
        return Result.ok(videoUrl);
    }

    /**
     * 获取所有的生成的视频
     */
    @GetMapping("/videoList")
    public Result<List<AiVideo>> videoList() {
        List<AiVideo> videoList = aiSercive.videoList();
        return Result.ok(videoList);
    }

    /**
     * 删除生成的视频
     */
    @DeleteMapping("/video/{id}")
    public Result<String> deleteVideo(@PathVariable Long id) {
        aiSercive.deleteVideo(id);
        return Result.ok();
    }
}